(clear) ; Test error conditions for load/save facts
(save-facts)
(save-facts 7)
(save-facts blah.tmp 7)
(save-facts blah.tmp hello)
(save-facts blah.tmp local bogus)
(remove blah.tmp)
(save-facts blah.tmp)
(load-facts)
(load-facts 7)
(load-facts blah.tmp bogus)
(remove blah.tmp)
(load-facts blah.tmp)
(bsave-facts)
(bsave-facts 7)
(bsave-facts blah.tmp 7)
(bsave-facts blah.tmp hello)
(bsave-facts blah.tmp local bogus)
(remove blah.tmp)
(bsave-facts blah.tmp)
(bload-facts)
(bload-facts 7)
(bload-facts blah.tmp bogus)
(remove blah.tmp)
(bload-facts blah.tmp)
(clear) ; Test Saving and Reloading
(load factsav.clp)
(reset)
(set-current-module MAIN)
(assert (A (x 1)) (B (x 1)) (B (x 2)))
(set-current-module BAR)
(assert (D (x 2)) (C (x 1)) (D (x 1)) (E (x 1)))
(set-current-module WOZ)
(assert (G (x 1)) (F (x 1)) (G (x 2)))
(set-current-module MAIN)
(facts *)
(facts)
(save-facts "Temp//fctsav1.fct" visible)
(save-facts "Temp//fctsav2.fct" local A)
(bsave-facts "Temp//fctsavb1.fct" visible)
(bsave-facts "Temp//fctsavb2.fct" local A)
(set-current-module BAR)
(facts)
(save-facts "Temp//fctsav3.fct" local C)
(save-facts "Temp//fctsav4.fct" visible B E)
(bsave-facts "Temp//fctsavb3.fct" local C)
(bsave-facts "Temp//fctsavb4.fct" visible B E)
(set-current-module WOZ)
(facts)
(save-facts "Temp//fctsav5.fct" local)
(save-facts "Temp//fctsav6.fct" visible F G E)
(bsave-facts "Temp//fctsavb5.fct" local)
(bsave-facts "Temp//fctsavb6.fct" visible F G E)
(set-current-module FOO)
(facts)
(save-facts "Temp//fctsav7.fct" local)
(save-facts "Temp//fctsav8.fct" visible)
(bsave-facts "Temp//fctsavb7.fct" local)
(bsave-facts "Temp//fctsavb8.fct" visible)
(reset)
(set-current-module MAIN)
(load-facts "Temp//fctsav1.fct")
(facts *)
(retract *)
(load-facts "Temp//fctsav2.fct")
(facts *)
(retract *)
(load-facts "Temp//fctsav3.fct")
(facts *)
(retract *)
(set-current-module BAR)
(load-facts "Temp//fctsav3.fct")
(facts *)
(retract *)
(load-facts "Temp//fctsav4.fct")
(facts *)
(retract *)
(set-current-module WOZ)
(load-facts "Temp//fctsav5.fct")
(facts *)
(retract *)
(load-facts "Temp//fctsav6.fct")
(facts *)
(retract *)
(set-current-module FOO)
(load-facts "Temp//fctsav7.fct")
(facts *)
(retract *)
(load-facts "Temp//fctsav8.fct")
(facts *)
(retract *)
(set-current-module MAIN)
(bload-facts "Temp//fctsavb1.fct")
(facts *)
(retract *)
(bload-facts "Temp//fctsavb2.fct")
(facts *)
(retract *)
(bload-facts "Temp//fctsavb3.fct")
(facts *)
(retract *)
(set-current-module BAR)
(bload-facts "Temp//fctsavb3.fct")
(facts *)
(retract *)
(bload-facts "Temp//fctsavb4.fct")
(facts *)
(retract *)
(set-current-module WOZ)
(bload-facts "Temp//fctsavb5.fct")
(facts *)
(retract *)
(bload-facts "Temp//fctsavb6.fct")
(facts *)
(retract *)
(set-current-module FOO)
(bload-facts "Temp//fctsavb7.fct")
(facts *)
(retract *)
(bload-facts "Temp//fctsavb8.fct")
(facts *)
(retract *)
(clear)

(deftemplate person 
   (multislot name)
   (multislot hobbies)
   (slot age (type INTEGER))
   (slot gender (allowed-values male female)))
(assert (factoid))
(assert (types a "bc" [def] 1 2.3))
(assert (colors red green blue))
(assert (people frank sally joe))
(assert (person (name Roger Downs) (age 33) (gender male) (hobbies reading running)))
(assert (person (name Jenny Smith) (age 25) (gender female) (hobbies movies softball)))
(bsave-facts "Temp//fctsavb9.fct")
(clear)

(deftemplate person 
   (multislot name)
   (multislot hobbies)
   (slot age (type INTEGER))
   (slot gender (allowed-values male female)))
(assert (people susan howard jane))
(bload-facts "Temp//fctsavb9.fct")
(facts)
(clear)

(deftemplate stuff
   (slot fa (type FACT-ADDRESS))
   (slot ea (type EXTERNAL-ADDRESS))
   (slot ia (type INSTANCE-ADDRESS)))
(assert (stuff))
(facts)
(defclass THING (is-a USER))
(make-instance t1 of THING)
(assert (stuff (fa (assert (colors red green blue))) (ia (instance-address [t1]))))
(facts)
(bsave-facts "Temp//fctsavb10.fct")
(reset)
(bload-facts "Temp//fctsavb10.fct")
(facts)
(clear)
(deftemplate cp (multislot v) (multislot a))

(assert (cp (v) (a))
        (cp (v 1) (a x))
        (cp (v 2 3) (a))
        (cp (v) (a y z)))
(bsave-facts "Temp//fctsavb11.fct")
(reset)
(bload-facts "Temp//fctsavb11.fct")
(facts)
